import WhtRequest from './index.js'

let request = null

export default {
    install: (app, options = {}) => {
        // 创建请求实例
        request = new WhtRequest(options)
        
        // Vue 3
        if (app.config?.globalProperties) {
            app.config.globalProperties.$whtRequest = request
        }
        // Vue 2
        else if (app.prototype) {
            app.prototype.$whtRequest = request
        }
        
        // 导出到 uni 对象上，方便在其他地方使用
        if (typeof uni !== 'undefined') {
            uni.$whtRequest = request
        }
    }
}
